import 'package:flutter/material.dart';
import 'package:flutter_project/config/theme_color.dart';

import '../../common/utils/screen_size_utils.dart';

class LineWithCircle extends StatelessWidget {
  int minute = 2;

  LineWithCircle({this.minute = 2, super.key});

  @override
  Widget build(BuildContext context) {
    double lineWidth = ScreenSizeUtils.deviceScreenWidth(context);
    return Column(
      children: [
        SizedBox(
          height: 15,
          width: (lineWidth-50)/5.0,
          child: CustomPaint(
            painter: LineWithCirclePainter(),
          ),
        ),
        Text(
          '$minute分钟',
          style: TextStyle(color: ThemeColor.checkNormalColor),
        )
      ],
    );
  }
}

class LineWithCirclePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint linePaint = Paint()
      ..color = Colors.blue
      ..strokeWidth = 2.0;

    Paint circlePaint = Paint()
      ..color = Colors.red
      ..style = PaintingStyle.fill;

    double circleRadius = size.height * 0.2;

    // 绘制横线
    canvas.drawLine(
      Offset(0, size.height / 2),
      Offset(size.width, size.height / 2),
      linePaint,
    );

    // 绘制圆形
    canvas.drawCircle(
      Offset(size.width / 2, size.height / 2),
      circleRadius,
      circlePaint,
    );
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}
